package com.dsl.tms.job.wms.insert;


import com.dsl.tms.datasource.DataSourceContextHolder;
import com.dsl.tms.entity.wmsdb.DwEntity;
import com.dsl.tms.mapper.wmsdb.DwMapper;
import org.mybatis.spring.SqlSessionTemplate;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.ArrayList;

@DisallowConcurrentExecution
public class InserDw implements Job,Serializable {

    private static final Logger log = LoggerFactory.getLogger(InserDw.class);

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        //切换数据库
        DataSourceContextHolder.setDBType("SCPRD_wmwhse1");
        DwMapper dwMapper = sqlSessionTemplate.getMapper(DwMapper.class);
        ArrayList<DwEntity> dwEntities = dwMapper.queryDw();
        for (DwEntity dwEntity:dwEntities){
            System.out.println(dwEntity.getSsa_no());
        }
        System.out.println("跑任务");
    }




}
